<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<ui:composition template="/WEB-INF/layout.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui">

    <ui:define name="content">
        <h:form id="form">
            <p:panel id="panel" header="Pesquisar Aluno">
                <p:outputLabel for="aluno" value="Informe o nome do aluno:"/>
                <p:spacer width="10" height="0" />
                <p:inputText id="aluno" value="#{alunoController.nomeAlunoDigitado}" required="true" size="50" maxlength="50"/>
                <p:spacer width="10" height="0" />
                <p:commandButton id="ok" icon="ui-icon-search" actionListener="#{alunoController.pesquisarAluno}" update="panel"/> <br/><br/>
                <p:growl id="growl" showDetail="true"/>

                <p:dataTable id="alunos" var="aluno"
                             value="#{alunoController.alunosDM}" 
                             style="width:100%;" 
                             rowKey="#{aluno.idAluno}"
                             rows="5"
                             selection="#{alunoController.alunoSelecionado}" 
                             selectionMode="single">
                    <p:ajax event="rowSelect" listener="#{alunoController.onRowSelect}"
                            update=":form:display :form:growl"  oncomplete="PF('alunoDialog').show()" />
                    <p:column headerText="Código">
                        #{aluno.idAluno}
                    </p:column>
                    <p:column headerText="Nome">
                        #{aluno.nome}
                    </p:column>
                    <p:column headerText="Data de Nascimento">
                        #{aluno.dataNasc}
                    </p:column>     
                </p:dataTable>


                <p:dialog id="dialog" header="Aluno Selecionado" widgetVar="alunoDialog" resizable="false"  
                          showEffect="fade" hideEffect="explode">  
                    <h:panelGrid id="display" columns="2" cellpadding="4">  
                        <h:outputText value="Nome:" />  
                        <h:outputText value="#{alunoController.alunoSelecionado.nome}" />  
                    </h:panelGrid>  
                </p:dialog>  

            </p:panel>
        </h:form>
    </ui:define>
</ui:composition>